<template>
    <div id="confirmBox" v-show="showBox">
        <div class="confirmBoxContent">
            <div v-if="useHtml" v-html="text"></div>
            <div v-else>{{text}}</div>
        </div>
        <p class="confirmBoxBtn">
            <span @click="button[0].ontap" class="whiteBtn" v-if="showBtn.showConfirm">{{button[0].text}}</span>
            <span @click="button[1].ontap" class="whiteBtn" v-if="showBtn.showCancel">{{button[1].text}}</span>
        </p>
    </div>
</template>

<script>
export default {
  data() {
    return {
      showBox: true,
      title: "",
      text: "",
      button: [],
      useHtml: false,
      showBtn:{
          showConfirm: true,
          showCancel: true
      }
    };
  },
  methods: {
    onClosed() {
      this.close();
    }
  }
};
</script>

<style scoped>
#confirmBox {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -150%);
  -webkit-transform: translate(-50%, -150%);
  -moz-transform: translate(-50%, -150%);
  -o-transform: translate(-50%, -150%);
  -ms-transform: translate(-50%, -150%);
  width: 520px;
  background: #f2f2f2;
  z-index: 1000;
  box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
  -webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
  -o-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
  -ms-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
  -moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
  border-radius: 6px;
}
div.confirmBoxContent{
    width: 100%;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    text-align: center;
}
div.confirmBoxContent>div{
    width: 100%;
    height: 40px;
    padding: 15px 15px 0 15px;
    font-size: 16px;
}
p.confirmBoxBtn{
    display: flex;
    justify-content: center;
}
p.confirmBoxBtn>span.whiteBtn{
    width: 58px;
    height: 28px;
    float: left;
    margin: 10px 2px;
    background: #f2f2f2;
    font-size: 14px;
}
p.confirmBoxBtn>span.whiteBtn:active{
    background: #79828F;
}
span.whiteBtn{
    display: block;
    text-align: center;
    background: #fff;
    color: #333;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid #333;
    height: 28px;
    line-height: 28px;
}
span.whiteBtn:active{
    background: #777;
    color: #fff;
}
</style>